<template>
  <n-scrollbar style="max-height: 80vh" class="box">
    <n-space vertical v-if="list.length > 0">
      <n-card
        hoverable
        class="card"
        v-for="(item, index) in list"
        :key="index"
        @click="click(item.questionUid)"
      >
        <n-avatar :size="36" :src="item.image" class="image" />
        <span class="text">
          {{ item.contactName }}在{{ item.questionTitle }}中@了你
        </span>
        <span class="time"> {{ item.time }} </span>
      </n-card>
    </n-space>
    <div class="blank" v-else>
      <img class="img" src="@assets/404.png" alt="" />
    </div>
  </n-scrollbar>
</template>

<script setup>
import api from '@/api/api'
const { Message } = api

const router = useRouter()
const list = ref([
  // {
  //   contactName: 'zy',
  //   questionTitle: 'qwe',
  //   questionUid: 1,
  //   time: "2020年1月2日",
  //   image: "1234",
  // },
])

const getAtList = () => {
  Message.getAtList({}).then((res) => {
    if (res.success) {
      list.value = res.list
    }
  })
}
onMounted(() => {
  getAtList()
})

const click = function (id) {
  router.replace('/forum/detail/' + id)
}
</script>

<style scoped lang="scss">
.box {
  text-align: right;
}
.card {
  position: relative;
  min-height: 60px;
}
.text {
  margin-right: 50px;
  font-weight: bold;
}
.image {
  position: absolute;
  right: 30px;
  transform: translate(0, -50%);
  top: 50%;
}
.blank {
  text-align: center;
  .img {
    display: block;
    margin: 0 auto;
    height: 20vh;
  }
}
</style>
